// import Cookies from 'js-cookie'
import { getCookie, setCookies, removeCookies } from 'cookies-next';

const TokenKey = 'UToken'
const SidKey = 'USid'
const OpenidKey = 'UOpenid'
const UidKey = 'Uid'
const options = {
  maxAge: 3600 * 24 * 30, // cookeie 修改为30天后过期
}

export function mCommit(key, value) {
  return setCookies(key, value, options)
}

export function mGet(key) {
  return getCookie(key)
}

export function mRemove(key) {
  return removeCookies(key)
}

export function getToken() {
  return getCookie(TokenKey)
}

export function setToken(token) {
  return setCookies(TokenKey, token, options)
}

export function removeToken() {
  return removeCookies(TokenKey)
}

export function getSid() {
  return getCookie(SidKey)
}

export function setSid(sid) {
  return setCookies(SidKey, sid, options)
}

export function removeSid() {
  return removeCookies(SidKey)
}

export function getOpenID() {
  return getCookie(OpenidKey)
}

export function setOpenID(sid) {
  return setCookies(OpenidKey, sid, options)
}

export function removeOpenID() {
  return removeCookies(OpenidKey)
}

export function getUID() {
  return getCookie(UidKey)
}

export function setUID(uid) {
  return setCookies(UidKey, uid, options)
}

export function removeUID() {
  return removeCookies(UidKey)
}
